/**
 * Created by Freeman on 2016/8/2.
 */
import React from 'react'
import {Route,IndexRoute} from 'react-router'
import App from './containers/App'
import Home from './components/Home'
import Login from './components/Login'
import Register from './components/Register'
import NotFound from './components/NotFound'
import Article from './components/Article'
import Mine from './components/Mine'
import Writer from './components/Writer'
import Profile from './components/Mine/Profile'
import Posts from './components/Mine/Posts'
import {redirectToBack,redirectToLogin} from './utils/authService'
export default (
    <Route path="/" component={App}>
        <IndexRoute component={Home} />
        <Route path="/login" component={Login} onEnter={redirectToBack} />
        <Route path="/sign_up" component={Register} />
        <Route path="/article/:id" component={Article} />
        <Route path="/writer" component={Writer} onEnter={redirectToLogin} />
        <Route path="/mine" component={Mine} onEnter={redirectToLogin}>{/*嵌套路由*/}
            <Route path="profile" component={Profile} onEnter={redirectToLogin}/>
            <Route path="posts" component={Posts} onEnter={redirectToLogin}/>
        </Route>
        <Route path="*" component={NotFound} />
    </Route>
)